﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Growatt.OutPutDataProcess
{
    [XmlRoot("section")]
    public class DwarfInfo
    {
        [XmlText]
        public string Text { get; set; }

        [XmlElement("name")]
        public string Name { get; set; }

        [XmlElement("compile_unit")]
        public List<CompileUnit> iter_CUs { get; set; }
    }



    [XmlRoot("compile_unit")]
    public class CompileUnit
    {
        [XmlText]
        public string Text { get; set; }

        [XmlAttribute("id")]
        public string ID { get; set; }

        [XmlElement("version")]
        public string Version { get; set; }

        [XmlElement("addr_size")]
        public string AddrSize { get; set; }

        [XmlElement("die")]
        public Die TopLevelDie { get; set; }
    }

    public class Die
    {
        [XmlText]
        public string Text { get; set; }

        [XmlAttribute("id")]
        public string ID { get; set; }

        [XmlElement("tag")]
        public string Tag { get; set; }

        [XmlElement("attribute")]
        public List<Attribute> Attributes { get; set; } = new List<Attribute>();

        [XmlElement("die")]
        public List<Die> Dies { get; set; } = new List<Die>();
    }

    public class Attribute
    {
        [XmlText]
        public string Text { get; set; }

        [XmlElement("type")]
        public string Type { get; set; }

        [XmlElement("form")]
        public string Form { get; set; }

        [XmlElement("value")]
        public Value Value { get; set; }
    }

    public class Value
    {
        [XmlText]
        public string Text { get; set; }

        [XmlElement("string")]
        public string StringValue { get; set; }

        [XmlElement("const")]
        public string ConstValue { get; set; }

        [XmlElement("ref")]
        public Ref RefValue { get; set; }

        [XmlElement("flag")]
        public string FlagValue { get; set; }

        [XmlElement("addr_class")]
        public string AddrClassValue { get; set; }

        [XmlElement("block")]
        public string BlockValue { get; set; }

        [XmlElement("addr")]
        public string AddrValue { get; set; }
    }

    public class Ref
    {
        [XmlAttribute("idref")]
        public string Idref { get; set; }
    }



    [XmlRoot("symbol_table")]
    public class SymbolTableSection
    {

        [XmlElement("symbol")]
        public List<Symbol> Symbols { get; set; }

        [XmlElement("elf32_sym")]
        public List<Symbolelf32_sym> Symbolself32 { get; set; }
    }


    [XmlRoot("string_table")]
    public class StringTable
    {
        [XmlElement("string_table_size")]
        public string StringTableSize { get; set; }

        [XmlElement("string")]
        public List<string> Strings { get; set; } = new List<string>();
    }
    public class Symbol
    {
        [XmlElement("index")]
        public string Index { get; set; }

        [XmlElement("name")]
        public string Name { get; set; }

        [XmlElement("kind")]
        public string Kind { get; set; }

        [XmlElement("section")]
        public string Section { get; set; }

        [XmlElement("storage_type")]
        public string StorageType { get; set; }

        [XmlElement("storage_class")]
        public string StorageClass { get; set; }

        [XmlElement("aux_count")]
        public string AuxCount { get; set; }

        [XmlElement("value")]
        public string Value { get; set; }

        [XmlElement("length")]
        public string Length { get; set; }

        [XmlElement("reloc_count")]
        public string RelocCount { get; set; }

        [XmlElement("line_count")]
        public string LineCount { get; set; }
    }

    public class Symbolelf32_sym
    {
        [XmlElement("index")]
        public string Index { get; set; }

        [XmlElement("st_name_string")]
        public string st_name_string { get; set; }

        [XmlElement("st_shndx")]
        public string st_shndx { get; set; }

        [XmlElement("st_visibility")]
        public string st_visibility { get; set; }

        [XmlElement("st_value")]
        public string Value { get; set; }

        [XmlElement("st_size")]
        public string Length { get; set; }

        [XmlElement("st_type")]
        public string st_type { get; set; }

        [XmlElement("st_bind")]
        public string st_bind { get; set; }

        [XmlElement("st_shndx_string")]
        public string st_shndx_string { get; set; }
    }

}